<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ShopOrders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('shop_orders', function (Blueprint $table) {
        $table->increments('id');
        $table->unsignedInteger('user_id');
        $table->string('o_num', 100);
        $table->string('getname', 10);
        $table->string('address', 255);
        $table->string('phone', 15);
        $table->tinyInteger('status')->comment('0为未支付;1为已取消;2为未发货;3已发货;4已完成;5为待评价;6用户已删除');
        $table->string('message', 100)->nullable();
        $table->dateTime('create_at');
        $table->timestamp('pay_at')->nullable();
        $table->timestamp('send_at')->nullable();
        $table->timestamp('over_at')->nullable();

        $table->foreign('user_id')
              ->references('id')->on('shop_home_users')
              ->onDelete('cascade');

      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
      Schema::dropIfExists('shop_orders');

    }
}
